package com.huage_01;

import java.util.Scanner;

public class SumSorce {
    public static void main(String[] args) {
        int[] arr = new int[6];
        Scanner sc = new Scanner(System.in);
        for(int i=0;i<arr.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委分数");
            arr[i] = sc.nextInt();
        }
        int maxSorce = getMax(arr);
        int minSorce = getMin(arr);
        int sorce = comSorce(arr,maxSorce,minSorce);
        System.out.println("最终成绩为" + sorce);
    }
    //去除最高分，最低分，计算平均分
    /*
        传参类型:int[],int,int
        返回值:int
     */
    private static int comSorce(int[] arr, int maxSorce, int minSorce) {
        int sum = 0;
        for (int j : arr) {
            sum += j;
        }
        int sorce = (sum-maxSorce-minSorce)/(arr.length-2);
        return sorce;
    }
    //取最大值
    /*
        传参类型:int[]
        返回值:int
     */
    private static int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(max <arr[i]){
                max =arr[i];
            }
        }
        return max;
    }
    //取最小值
    /*
        传参类型:int[]
        返回值:int
     */
    private static int getMin(int[] arr) {
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(min >arr[i]){
                min =arr[i];
            }
        }
        return min;
    }

}
